

def is_false(num):
    if num % 10000 == 0:
        return True
    return False


def format_num(num):
    def strofsize(num, level):
        if level >= 2:
            return num, level
        elif num >= 10000:
            if is_false(num):
                num //= 10000
            else:
                num /= 10000
            level += 1
            if int(num) - round(num, 1) == 0.0:
                return strofsize(int(num), level)
            return strofsize(round(num, 1), level)
        else:
            return num, level

    units = ['', '万', '亿']
    num, level = strofsize(num, 0)
    if level > len(units):
        level -= 1
    return '{}{}'.format(num, units[level])
